package com.chujian.sys.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.chujian.framework.core.IId;
import com.chujian.framework.core.IIdName;
import com.chujian.framework.core.base.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 菜单表
 *
 * @author yj
 * @since 2021-08-03
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("sys_menu")
@KeySequence("sys_menu_seq")
public class SysMenu extends BaseEntity implements IId, IIdName {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "菜单id")
    @TableId("menu_id")
    private Long menuId;

    @ApiModelProperty(value = "菜单名称")
    @TableField("menu_name")
    private String menuName;

    @ApiModelProperty(value = "组件名称")
    @TableField("component_name")
    private String componentName;

    @ApiModelProperty(value = "菜单类型（1：菜单 2：功能 3：操作）")
    @TableField("menu_type")
    private Integer menuType;

    @ApiModelProperty(value = "父id")
    @TableField("menu_pid")
    private Long menuPid;

    @ApiModelProperty(value = "排序")
    @TableField("order_no")
    private Integer orderNo;

    @ApiModelProperty(value = "图标")
    @TableField("icon")
    private String icon;

    @ApiModelProperty(value = "路由地址")
    @TableField("path")
    private String path;

    @ApiModelProperty(value = "组件地址")
    @TableField("component_url")
    private String componentUrl;

    @ApiModelProperty(value = "启用、禁用")
    @TableField("status")
    private Boolean status;

    @ApiModelProperty(value = "是否可见")
    @TableField("is_visible")
    private Boolean isVisible;

    @ApiModelProperty(value = "权限标识")
    @TableField("auth_mark")
    private String authMark;

    @ApiModelProperty(value = "是否缓存")
    @TableField("is_cache")
    private Boolean isCache;


    @ApiModelProperty(value = "拓展json")
    @TableField("exp_json")
    private String expJson;

    @ApiModelProperty(value = "菜单方案ID（菜单模板ID）")
    @TableField("menu_template_id")
    private Integer menuTemplateId;

    @ApiModelProperty(value = "平台id")
    @TableField("plat_id")
    private Integer platId;

    @ApiModelProperty(value = "产品id")
    @TableField("prod_id")
    private Long prodId;

    @ApiModelProperty(value = "账套id")
    @TableField("ac_id")
    private Long acId;

    @ApiModelProperty(value = "1tab页签（默认） 2新窗口 3外连接")
    @TableField("open_type")
    private Integer openType;

    @TableField(value = "delete_flag")
    protected Boolean deleteFlag;

    // ++++++ 系统拓展 +++++++
    @TableField(exist = false)
    private Map<String, String> query = new HashMap<>();

    @Override
    public Long getId() {
        return this.menuId;
    }

    @Override
    public void setId(Serializable id) {
        if (null != id) {
            this.menuId = Long.parseLong("" + id);
        }
    }

    @Override
    public String getName() {
        return this.getMenuName();
    }

    // ++++++ 业务拓展 +++++++
    @TableField(exist = false)
    private List<SysMenu> children;
}
